import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

const routes: RouteRecordRaw[] = [
    { path: '/index.html', redirect: '/' },
    { path: '/', component: () => import('@/views/Index.vue') },
    { path: '/login', component: () => import('@/views/Login.vue') },
    { path: '/register', component: () => import('@/views/Register.vue') },

    // 设计师
    {
        path: '/designer',
        component: () => import('@/views/BasicPage.vue'),
        children: [
            { path: '', component: () => import('@/views/designer/Home.vue') },
            { path: ':id(\\d+)', component: () => import('@/views/designer/Designer.vue'), props: true },
            { path: 'register', component: () => import('@/views/designer/Register.vue') },
            {
                path: 'center',
                component: () => import('@/views/designer/Center.vue')
            },
            { path: 'createalbum', component: () => import('@/views/designer/CreateAlbum.vue') },
            { path: 'album/:id(\\d+)', component: () => import('@/views/designer/AlbumInfo.vue'), props: true },
            { path: 'album/:id(\\d+)/createworks', component: () => import('@/views/designer/CreateWorks.vue'), props: true },
            { path: 'works/:id(\\d+)', component: () => import('@/views/designer/DesignWorks.vue'), props: true },
        ]
    },
    // 用户中心
    {
        path: '/account',
        component: () => import('@/views/AccountBasicPage.vue'),
        children: [
            { path: '', component: () => import('@/views/account/Info.vue') },
            { path: 'password', component: () => import('@/views/account/Password.vue') },
            { path: 'article', component: () => import('@/views/account/Article.vue') },
        ]
    },
    //文章
    {
        path: '/article/:id(\\d+)',
        component: () => import('@/views/Article.vue'),
        props: true
    },
    { 
        path: '/article/createarticle', 
        component: () => import('@/views/account/CreateArticle.vue') 
    },
    // 管理中心
    {
        path: '/admin',
        component: () => import('@/views/AdminBasicPage.vue'),
        children: [
            { path: '', component: () => import('@/views/admin/Home.vue') },
            { path: 'user', component: () => import('@/views/admin/User.vue') },
            { path: 'article', component: () => import('@/views/error/404.vue') },
            { path: 'dict_category', component: () => import('@/views/admin/DictCategory.vue') },
            { path: 'dict', component: () => import('@/views/admin/Dict.vue') },
        ]
    },

    { path: '/:pathMatch(.*)*', component: () => import('@/views/error/404.vue') },
]

const routerHistory = createWebHistory()
export default createRouter({
    history: routerHistory,
    routes
})